package com.example.springboot.service.impl;


import com.example.springboot.entity.Applications;
import com.example.springboot.mapper.JobApplicationMapper;
import com.example.springboot.service.JobApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class JobApplicationServiceImpl implements JobApplicationService {

    @Autowired
     private JobApplicationMapper jobApplicationMapper;


    @Override
    public void applyForJobs(Long studentId, List<Long> jobIds) {
        for (Long jobId : jobIds) {
            Applications applications = new Applications();
            applications.setJob_id(Math.toIntExact(jobId));
            applications.setStudent_id(Math.toIntExact(studentId));
            applications.setApplication_status("Submitted"); // 默认状态为已提交

            // 设置申请时间和更新时间
//            LocalDateTime now = LocalDateTime.now(); // 获取当前时间
//            applications.setApplied_at(new Date());
//            applications.setUpdated_at(new Date());

            JobApplicationMapper.createApplication(applications);
        }
    }

    @Override
    public List<Applications> findAllApplications() {
        return jobApplicationMapper.findAllApplications();
    }

}
